package com.chujian.sys.vo;

import cn.hutool.core.map.MapBuilder;
import cn.hutool.core.map.MapUtil;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;

import java.util.Map;

/**
 * @author ：chujian
 * @since ：2021-10-20
 * 小程序功能定义
 */
@Getter
@Setter
@NoArgsConstructor
@Accessors(chain = true)
public class MaOp {

    // navType
    public static final int NAV_TYPE_PAGE = 10; // 页面
    public static final int NAV_TYPE_H5 = 11; // h5
    public static final int NAV_TYPE_MINIP = 12; // 小程序
    public static final int NAV_TYPE_SCAN = 13; // 扫一扫
    public static final int NAV_TYPE_TABBAR = 14; // tabbar页面

    // 属性
    private Long id;
    private String url;
    private String iconPath;
    private String name;
    private boolean needLogin = true;
    private Integer navType = NAV_TYPE_PAGE;

    // 拓展
    private MapBuilder<String, Object> mapBuilder = MapUtil.builder();

    public MaOp(Long id, String url, String iconPath, String name, Integer navType) {
        this.id = id;
        this.url = url;
        this.iconPath = iconPath;
        this.name = name;
        this.navType = navType;
    }

    public MaOp ext(String key, Object value) {
        mapBuilder.put(key, value);
        return this;
    }

    public Map<String, Object> toMap() {
        return mapBuilder
                .put("id", id)
                .put("url", url)
                .put("iconPath", iconPath)
                .put("name", name)
                .put("needLogin", needLogin)
                .put("navType", navType)
                .build();
    }

}
